package mis.module.base.service.impl;

import java.util.List;

import mis.module.base.dao.ProductDao;
import mis.module.base.model.Iproduct;
import mis.module.base.model.Product;
import mis.module.base.service.ProductService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class ProductServiceImpl implements ProductService{
	@Autowired
	private ProductDao productDao;
	@Override
	public void saveProduct(Product product) {
		// TODO Auto-generated method stub
		productDao.save(product);
	}

	@Override
	public void updateProduct(Product product) {
		// TODO Auto-generated method stub
		productDao.update(product);
	}

	@Override
	public void deleteProduct(int id) {
		// TODO Auto-generated method stub
		productDao.deleteById(id);
	}

	@Override
	public List<Product> findAllProduct(int page, int rows, String sort,
			String order) {
		// TODO Auto-generated method stub
		return productDao.findAll(page, rows, sort, order);
	}

	@Override
	public int getTotal() {
		// TODO Auto-generated method stub
		return productDao.countAll();
	}

	@Override
	public boolean isExist(String productNo) {
		// TODO Auto-generated method stub
		boolean flag = false;
		String hql="from Product as p where p.productNo="+productNo;
		if (productDao.find(hql).size()>0){
			flag = true;
		}
		return flag;
	}

	public ProductDao getProductDao() {
		return productDao;
	}

	public void setProductDao(ProductDao productDao) {
		this.productDao = productDao;
	}

	@Override
	public List<Iproduct> changeList(List<Product> list) {
		// TODO Auto-generated method stub
		return productDao.changeList(list);
	}

	 

}
